﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Diagnostics;

namespace TextToSpeechEngine
{
    public partial class MainForm : Form
    {
        //variables
        TTSEngine ttsEngine;
        Boolean databasesLoaded = false;

        public MainForm()
        {
            InitializeComponent();

            ttsEngine = new TTSEngine();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Debug.Write(textToBeReadTextBox.Text + " waha! \n");

            if (databasesLoaded) ttsEngine.readLine(textToBeReadTextBox.Text);
            else MessageBox.Show("Load databases first!");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            /*
            //for debugging
            ttsEngine.LoadFromFile(
                "C:\\Documents and Settings\\Admin\\My Documents\\Visual Studio 2008\\Projects\\TextToSpeechEngine\\TextToSpeechEngine\\phonemesounds\\phonemedatabase2",
                "C:\\Documents and Settings\\Admin\\My Documents\\Visual Studio 2008\\Projects\\TextToSpeechEngine\\TextToSpeechEngine\\phonemesounds\\wordphenomenedatabase.txt");

            databasesLoaded = true;
            */
            
            //choose files for the phoneme database and the word representation database
            OpenFileDialog openFileDialogPhoneme = new OpenFileDialog();
            OpenFileDialog openFileDialogWord = new OpenFileDialog();
            MessageBox.Show("Select phoneme database");
            if (openFileDialogPhoneme.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("Select word representation database");
                if (openFileDialogWord.ShowDialog() == DialogResult.OK)
                {
                    Debug.Write(openFileDialogPhoneme.FileName + " waha2!! " + openFileDialogWord.FileName + "\n");

                    ttsEngine.LoadFromFile(openFileDialogPhoneme.FileName, openFileDialogWord.FileName);

                    databasesLoaded = true;
                }
            }

        }
    }
}
